using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel.Composition;
using TrackMe.Apps.Integration.TFS;
using TrackMe.Apps.Views;

namespace TrackMe.Apps.VM
{
	[Export]
	public class TfsVM : BasicViewModel<ITfsView>
	{
		private readonly IDatabase database;

		[ImportingConstructor]
		public TfsVM(ITfsView view, IDatabase database) : base(view)
		{
			this.database = database;
			LoadQueries();
		}

		private void LoadQueries()
		{
			foreach(var serverInfo in database.TfsServerList())
			{
				var server = new TfsConnection(serverInfo.Url); 
				Items = server.WorkItems(serverInfo.LastSyncTime);
			}
		}

		public IList<ITfsWorkItem> Items { get; private set; }
	}
}